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

Re: [PATCH 1/6] rebase -i: Add the "ref" command

From
Greg Price <price@mit.edu>
Date
Jun 28, 2011, 11:15 UTC
Message-ID
<20110628111553.GU5771@dr-wily.mit.edu>
In-Reply-To
<7vd3hzxgbn.fsf@alter.siamese.dyndns.org>
Thanks for the review.
On Mon, Jun 27, 2011 at 11:46:52AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> Greg Price <price@MIT.EDU> writes:
> 
> > ...
> > +		if ! grep -Fq " $refname" "$state_dir"/oldrefs 2>/dev/null
> > +		then
> > +			echo "$sha1 $refname" >> "$state_dir"/oldrefs
> 
> (Style) Extra SP between ">>" and "$state_dir/oldrefs"

Hmm -- it looks like the prevalent style in the codebase is actually to include the space:

greg@gouda:~/w/git$ git grep -c '>>[^ ]' v1.7.6 git-*.sh v1.7.6:git-bisect.sh:3 v1.7.6:git-instaweb.sh:2 v1.7.6:git-rebase--interactive.sh:2 v1.7.6:git-stash.sh:1 greg@gouda:~/w/git$ git grep -c '>> ' v1.7.6 git-*.sh v1.7.6:git-am.sh:1 v1.7.6:git-filter-branch.sh:1 v1.7.6:git-instaweb.sh:8 v1.7.6:git-rebase--interactive.sh:10 v1.7.6:git-rebase--merge.sh:1

and in particular in git-rebase--interactive.sh. But I could do it either way.

Show 14 quoted lines
> > @@ -332,6 +334,15 @@ skip)
> >  abort)
> >  	git rerere clear
> >  	read_basic_state
> > +	[ -n "$oldrefs" ] && echo "$oldrefs" | while read sha1 ref
> 
> (Style) I think almost everybody else spells out "test".  Also please
> break line before the while, like this:
> 
> 	test -n "$oldrefs" &&
> 	echo "$oldrefs" |
> 	while read sha1 ref
>         do
>         	...
Sure, done.
> > +	do
> > +		if test "(null)" = $sha1
> 
> Who is giving you "(null)"???

I am, myself -- it's what the 'ref' implementation in git-rebase--interactive.sh uses to indicate that a ref had not existed and should be deleted on abort.

+       ref)
+               mark_action_done
+               refname=$sha1
+               sha1=$(git rev-parse --quiet --verify "$refname" \
+                       || echo "(null)")
+               if ! grep -Fq " $refname" "$state_dir"/oldrefs 2>/dev/null
+               then
+                       echo "$sha1 $refname" >> "$state_dir"/oldrefs
+               fi

I could change it to something like "-". It needs to be something that the 'read' builtin, as used at the top of the loop, treats as a word.

Greg
Previous: Junio C HamanoNext: Greg Price
Message 4 of 24 in “rebase: command "ref" and options --rewrite-{refs,heads,tags}”
  1. 0/6 rebase: command "ref" and options --rewrite-{refs,heads,tags}Greg Price, Jun 27, 2011
  2. 1/6 rebase -i: Add the "ref" commandGreg Price, Oct 10, 2009
  3. Junio C HamanoJun 27, 2011
  4. Greg PriceJun 28, 2011
  5. 2/6 pretty: Add %D for script-friendly decorationGreg Price, Nov 18, 2009
  6. Junio C HamanoJun 27, 2011
  7. 4/6 rebase: --rewrite-{refs,heads,tags} to pull refs along with branchGreg Price, Nov 18, 2009
  8. Phil HordJun 27, 2011
  9. Greg PriceJun 28, 2011
  10. 3/6 for-each-ref: --stdin to match specified refs against patternGreg Price, Jan 7, 2010
  11. 5/6 t/lib-rebase.sh: pass through ref commandsGreg Price, Jan 25, 2010
  12. 6/6 rebase --rewrite-refs: testsGreg Price, Jan 25, 2010
  13. Phil HordJun 27, 2011
  14. Greg PriceJun 28, 2011
  15. Junio C HamanoJun 27, 2011
  16. Greg PriceJun 28, 2011
  17. Junio C HamanoJun 27, 2011
  18. Greg PriceJun 28, 2011
  19. Greg PriceJun 28, 2011
  20. Ramkumar RamachandraJun 30, 2011
  21. Sverre RabbelierAug 3, 2011
  22. Greg PriceAug 3, 2011
  23. Junio C HamanoJun 27, 2011
  24. Greg PriceJun 28, 2011

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.