Does Git warn me if a shorthand commit ID can refer to 2 different commits? -


In the ID,

cee157eb799af829a9a0c42c0915f55cd29818d4 and cee1577fecf6fc5369a80bd6e926ac5f864a754b

Git Warn me if I type in git logs cee157 ? (Or Git 1.8.5.2 (Apple Git-48) allows me to type in Git log cee1 ).

I think it should be, although I can not find any official source that says it will be.

This should give you something like this:

  $ git log Cee157 Error: Small SHA1 cee157 is unclear Error: Small SHA1 cee157 is unclear. Fatal: Uncertainty logic 'CE 157': unknown modification or path in the work tree. Use '-' to separate the path from the modifications, such as: 'git & lt; Command & gt; [& Lt; Research & gt; ...] - [& LT; File & gt; ...] ' 

I have just tested this on a real Git repository, thus finding it with duplicate prefixes:

  git rev- List master | Cut-C-4 Sort | UNIK-C | Sort-nr | Head  

takes the list of amendments in master , removes the first 4 characters and removes the rest, counts the duplicate and the numerical form Sortes from ~ 1500 in a relatively small repository of the commodity I got some modifications with a common 4 digit prefix. I have chosen a 4 digit prefix because it is the smallest legal length supported by Git. (It does not even work with 3 digits or less, is not ambiguous.)

Btw It was not a typo, I do not know why error message about shadowed SHA1 appears twice, Regardless of this, tried with duplicate SHA1 (2 and 3):

  Error: Small SHA1 cee157 is unclear. Error: Small SHA1 cee157 is unclear.  

(but the stderr ) is actually nothing but the entire output on stderr , stdout .)

Testing in Windows:

  $ git --version git version 1.8.1.msysgit.1  

I think It's safe to say that if your version> = 1.8.1, then Git will warn you of duplicates. (It will refuse to work with a duplicate.) I think very old versions have worked like this.

UPDATE

While doing this test, you must have at least 4 digits SHA1 ( due to int minimum_abbrev = 4 Thanks for pointing to that!)


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -