git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git does the wrong thing with ambiguous names

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jun 7, 2007, 14:41 UTC
Message-ID
<46681932.9060808@nrlssc.navy.mil>
In-Reply-To
<20070607000100.GE3969@steel.home>
Alex Riesen wrote:
> Alex Riesen, Thu, Jun 07, 2007 01:33:27 +0200:
>> Alex Riesen, Thu, Jun 07, 2007 00:58:26 +0200:
>>> Brandon Casey, Thu, Jun 07, 2007 00:13:48 +0200:
[snip]
Show 17 quoted lines
> This one is much shorter and less friendly. Suggested by Junio on irc.
> It makes checkout always prefer a branch.
> 
> diff --git a/git-checkout.sh b/git-checkout.sh
> index 6b6facf..282c84f 100755
> --- a/git-checkout.sh
> +++ b/git-checkout.sh
> @@ -67,6 +67,8 @@ while [ "$#" != "0" ]; do
>  			new_name="$arg"
>  			if git-show-ref --verify --quiet -- "refs/heads/$arg"
>  			then
> +				rev=$(git-rev-parse --verify "refs/heads/$arg^0" 2>/dev/null)
> +				new="$rev"
>  				branch="$arg"
>  			fi
>  		elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)
> 
This doesn't work.

Now the working directory contents are never updated when switching branches.

Run my test script, or add an 'echo "some data" > a' in your shell code so that the two branches have different contents.

-brandon
Previous: Alex RiesenNext: Brandon Casey
Message 5 of 6 in “git does the wrong thing with ambiguous names”
  1. Brandon CaseyJun 6, 2007
  2. Alex RiesenJun 6, 2007
  3. Alex RiesenJun 6, 2007
  4. Alex RiesenJun 7, 2007
  5. Brandon CaseyJun 7, 2007
  6. Brandon CaseyJun 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.