Re: [PATCH v5 4/4] git-rebase: add keep_empty flag
- From
Clemens Buchacher <drizzd@aon.at>
- Date
- Apr 15, 2012, 09:33 UTC
- Message-ID
- <20120415093302.GA6263@ecki>
- In-Reply-To
- <1334342707-3326-5-git-send-email-nhorman@tuxdriver.com>
On Fri, Apr 13, 2012 at 02:45:07PM -0400, Neil Horman wrote:
> > Add a command line switch to git-rebase to allow a user the ability to specify > that they want to keep any commits in a series that are empty.
Thanks. That should be useful.
Show 6 quoted lines
> +is_empty_commit() {
> + ptree=$(git rev-parse "$1"^{tree})
> + pptree=$(git rev-parse "$1"^^{tree})
> + return $(test "$ptree" = "$pptree")
> +}
> +What's the extra leading 'p' for? Any reason not to use 'tree' and 'ptree'?
Show 9 quoted lines
> pick_one () {
> ff=--ff
> +
> + if is_empty_commit $@
> + then
> + empty_args="--allow-empty"
> + fi
> +
> case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esacYou do not handle the case where pick_one is called with -n. I think you need to move the case statement in front and then call is_empty_commit $sha1.
Not that it matters after this change, but in general using $@ without quotes looks wrong to my eyes.
Show 16 quoted lines
> @@ -780,9 +792,17 @@ git rev-list $merges_option --pretty=oneline --abbrev-commit \ > sed -n "s/^>//p" | > while read -r shortsha1 rest > do > + > + if test -z "$keep_empty" && is_empty_commit $shortsha1 > + then > + comment_out="# pick" > + else > + comment_out="pick" > + fi > + > if test t != "$preserve_merges" > then > - printf '%s\n' "pick $shortsha1 $rest" >> "$todo" > + printf '%s\n' "$comment_out $shortsha1 $rest" >> "$todo"
How about setting comment_out="# " or comment_out="" instead and then
printf '%s%s\n' "$comment_out" "pick $shortsha1 $rest" >> "$todo"
That would read more natural to me.