Re: Possible bug report: git checkout tag problem

2018-01-08 Thread Johannes Schindelin
Hi Myles,

On Mon, 8 Jan 2018, Myles Fong wrote:

> Brief description:
> When two tags are pointing to the same commit, e.g. tagA and tagB, if I
> do `git checkout tagA` then `git checkout tagB`,  and then `git status`,
> it shows `HEAD detached at tagA`
> 
> Expected behaviour:
> I'm expecting it to show `HEAD detached at tagB`, though I understand
> this makes no difference for the repo code, but still a bit confusing
> for me.

The problem here is that Git understands something different from what you
intended: if you say `git checkout `, Git is mostly interested
in the revision, i.e. the commit. Only if that parameter refers to a local
branch name (which is the only type of ref Git expects to advance via the
worktree) does it switch to a named branch. Otherwise it switches to what
I like to call "unnamed branch" (and which for historical reasons is
called "detached HEAD" by Git, something that is unlikely to be understood
without explicit explanation).

Now, as a convenience, Git tries to name the revision when it is on such
an unnamed branch. If a tag points to it, it uses the name of that tag to
describe it. If *multiple* tags point to it, it uses the newest one.

That's why you see what you see. It is intended behavior...

Ciao,
Johannes


Possible bug report: git checkout tag problem

2018-01-07 Thread Myles Fong
Hi,

Brief description:
When two tags are pointing to the same commit, e.g. tagA and tagB, if I do `git 
checkout tagA` then `git checkout tagB`,  and then `git status`, it shows `HEAD 
detached at tagA`

Expected behaviour:
I'm expecting it to show `HEAD detached at tagB`, though I understand this 
makes no difference for the repo code, but still a bit confusing for me.

Found workaround:
If I do an extra step `git checkout master`, followed by `git checkout tagB`,  
and then `git status`, it shows `HEAD detached at tagB` as expected. ("master" 
can be any branch name)

Affected version:
This happens with the latest git version 2.14.3.

Detailed background:
We have a system consists of many git repos, and are using tags of global 
version numbers to ensure the same version of repos are deployed in the whole 
system. Sometimes when we have a new minor version of the system, there is no 
new commits for some repos. Still we need a new version tag for those repos to 
match the system version number, so we put a new version tag pointing to the 
same commit as the previous version tag. This is how we ran into the above 
situation and I was suspecting that our deploying script didn't run properly 
when I see `HEAD detached at {old-version}` in some locations of a 
{new-version} system.
I'm not sure if this is an expected behaviour or not because I didn't found any 
useful information after some Goolgling, except the following discussion.

Related discussion:
I found this discussion to be related to the same problem:
https://stackoverflow.com/questions/30631000/git-checkout-tag-issues-tag-is-unchanged/30631434#30631434

Regards,
Myles Fong




Re: Fwd: Possible bug report: `git commit -ammend`

2013-11-15 Thread Matthieu Moy
rhys evans rhys.ev...@ft.com writes:

 I ran `git commit -ammend` on a repo where 1 out of 3 files changed
 were staged for commit.

 I would've expected an error to be thrown due to the double typo but
 instead it committed all 3 files with the message 'mend'.

 So it looks like it interpreted it as `git commit -a -m 'mend'`.

Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f).
Git does a special-case for -amend to avoid confusion:

  $ git commit -amend
  error: did you mean `--amend` (with two dashes ?)

But it did not special-case the double-typo.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fwd: Possible bug report: `git commit -ammend`

2013-11-15 Thread Duy Nguyen
On Fri, Nov 15, 2013 at 10:54 PM, Matthieu Moy
matthieu@grenoble-inp.fr wrote:
 rhys evans rhys.ev...@ft.com writes:

 I ran `git commit -ammend` on a repo where 1 out of 3 files changed
 were staged for commit.

 I would've expected an error to be thrown due to the double typo but
 instead it committed all 3 files with the message 'mend'.

 So it looks like it interpreted it as `git commit -a -m 'mend'`.

 Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f).
 Git does a special-case for -amend to avoid confusion:

   $ git commit -amend
   error: did you mean `--amend` (with two dashes ?)

 But it did not special-case the double-typo.

-m taking a string without a space or '=' increases the risk of this
typo. If it does require '=' or ' ' after -m then -ammend is more
likely to be rejected. Anybody know why we should support -mabc,
besides convenient?
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fwd: Possible bug report: `git commit -ammend`

2013-11-15 Thread Jeff King
On Sat, Nov 16, 2013 at 10:28:36AM +0700, Duy Nguyen wrote:

  Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f).
  Git does a special-case for -amend to avoid confusion:
 
$ git commit -amend
error: did you mean `--amend` (with two dashes ?)
 
  But it did not special-case the double-typo.
 
 -m taking a string without a space or '=' increases the risk of this
 typo. If it does require '=' or ' ' after -m then -ammend is more
 likely to be rejected. Anybody know why we should support -mabc,
 besides convenient?

For flags with optional arguments, -m abc would not work (we do not
know if abc is the argument or the next flag). An example of such a
flag is git status -uall.

We could disallow it for mandatory options, but that would create an
inconsistency in the option parsing.

Other than that, I think it is mostly convenience and compatibility with
other option-parsing systems.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Possible bug report

2013-04-26 Thread Junio C Hamano
Pierre-François CLEMENT lik...@gmail.com writes:

 As you can see, the --cumulative lines seem to be duplicated, though
 the computed stats aren't exactly the same... It appears when you
 combine the --cumulative option with either --stat, --numstat or
 --shortstat (but not --dirstat) ...

Thanks for a report.

I do not think the deprecated --cumulative command line option was
ever designed to be used with anything but --dirstat.

It was a UI mistake to make it look like an independent option,
which was corrected with 333f3fb0c530 (Refactor --dirstat parsing;
deprecate --cumulative and --dirstat-by-file, 2011-04-29) and the
fix shipped back in v1.7.6. Since that release we do not even
mention the option in the manual.

These days, the right way to spell it is as an option parameter to
the --dirstat option itself (e.g. --dirstat=cumulative).

The parser to parse --cumulative as a command line argument was kept
so that people who were used to --dirstat --cumulative do not have
to see an error from the command line parser.  We could have made
--cumulative with other kind of stat an error back then, but we
didn't. I suspect that we thought it would be sufficient to not
document --cumulative as a standalone option, but I do not recall
the details.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html