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

Re: [PATCH] rebase -i: avoid 'git reset' when possible

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 1, 2009, 21:57 UTC
Message-ID
<alpine.DEB.1.00.0903012242180.10279@pacific.mpi-cbg.de>
In-Reply-To
<7vvdqt8wob.fsf@gitster.siamese.dyndns.org>
Hi,
On Sun, 1 Mar 2009, Junio C Hamano wrote:
Show 51 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> > index 3dc659d..a9617a2 100755
> > --- a/git-rebase--interactive.sh
> > +++ b/git-rebase--interactive.sh
> > @@ -442,6 +442,27 @@ do_rest () {
> >  	done
> >  }
> >  
> > +# skip picking commits whose parents are unchanged
> > +skip_unnecessary_picks () {
> > +	current=$ONTO
> > +	i=0
> > +	while read command sha1 rest
> > +	do
> > +		test pick = "$command" &&
> > +		test $current = "$(git rev-parse $sha1^)" ||
> > +		break
> > +		current=$(git rev-parse $sha1)
> > +		i=$(($i+1))
> > +	done < "$TODO"
> > +	test $i = 0 || {
> > +		sed -e "${i}q" < "$TODO" >> "$DONE" &&
> > +		sed -e "1,${i}d" < "$TODO" >> "$TODO".new &&
> > +		mv -f "$TODO".new "$TODO" &&
> > +		ONTO=$current ||
> > +		die "Could not skip $i pick commands"
> > +	}
> > +}
> 
> I do not think you have to count and then run two sed.
> 
> 	this=$ONTO
> 	skip_pick=t
> 	while read command sha1 rest
> 	do
> 		sha1=$(git rev-parse "$sha1")
>         	case "$skip_pick,$command" in
>                 t,pick | t,p)
> 			if test "$this" = "$sha1"
>                         then
> 				echo >&3 "$command $sha1 $rest"
>                         	this="$sha1"
> 				continue
> 			fi
> 		esac                        
> 		skip_pick=f
>                 echo "$command $sha1 $rest"
> 	done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
> 	...
Or even
	current=$ONTO
	fd=3
	while read command sha1 rest
	do
		case "$fd,$command,$current" in
		3,pick,"$sha1"*|t,p,"$sha1"*)
			current=$sha1
			;;
		*)
			fd=1
			;;
		esac
		echo "$command $sha1 $rest" >&$fd
	done < "$TODO" > "$TODO.new" 3>> "$DONE" &&
	mv "$TODO.new" "$TODO"
Hmm?

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 16 in “[RFH] rebase -i optimization”
  1. Sverre RabbelierFeb 26, 2009
  2. Johannes SchindelinFeb 26, 2009
  3. Sverre RabbelierFeb 26, 2009
  4. Johannes SchindelinFeb 27, 2009
  5. Sverre RabbelierFeb 27, 2009
  6. rebase -i: avoid 'git reset' when possibleJohannes Schindelin, Feb 27, 2009
  7. Sverre RabbelierFeb 27, 2009
  8. Johannes SchindelinFeb 27, 2009
  9. Junio C HamanoMar 1, 2009
  10. Johannes SchindelinMar 1, 2009
  11. Junio C HamanoMar 3, 2009
  12. Johannes SchindelinMar 3, 2009
  13. rebase -i: avoid 'git reset' when possibleJohannes Schindelin, Mar 3, 2009
  14. Johannes SixtMar 3, 2009
  15. Johannes SchindelinMar 3, 2009
  16. Sitaram ChamartyFeb 27, 2009

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.