From 4826875c14554d4fa5098ddf9499c33cb7b9001b Mon Sep 17 00:00:00 2001 From: Nazri Ramliy Date: Fri, 3 Oct 2014 09:59:38 +0800 Subject: [PATCH] rebase: Add --show-files option --- Documentation/git-rebase.txt | 8 ++++++++ git-rebase--interactive.sh | 13 +++++++++++++ git-rebase.sh | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index f14100a..4996bc4 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -383,6 +383,14 @@ If `--autosquash` is used, "exec" lines will not be appended for the intermediate commits, and will only appear at the end of each squash/fixup series. +-F:: +--show-files:: + Append the list of affected files after each line creating a commit in + the history. ++ +This option can only be used with the `--interactive` option +(see INTERACTIVE MODE below). + --root:: Rebase all commits reachable from , instead of limiting them with an . This allows you to rebase diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b64dd28..32b4266 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -820,6 +820,11 @@ add_exec_commands () { mv "$1.new" "$1" } +print_affected_files () { + commit_sha1="$1" + git show --raw $commit_sha1|awk '/^:/ {print " '"${comment_char}"' "$0}' +} + # The whole contents of this file is run by dot-sourcing it from # inside a shell function. It used to be that "return"s we see # below were not inside any function, and expected to return @@ -978,6 +983,10 @@ do if test t != "$preserve_merges" then printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo" + if test -n "$show_files" + then + print_affected_files $shortsha1 >> "$todo" + fi else sha1=$(git rev-parse $shortsha1) if test -z "$rebase_root" @@ -997,6 +1006,10 @@ do then touch "$rewritten"/$sha1 printf '%s\n' "${comment_out}pick $shortsha1 $rest" >>"$todo" + if test -n "$show_files" + then + print_affected_files $sha1 >> "$todo" + fi fi fi done diff --git a/git-rebase.sh b/git-rebase.sh index 55da9db..4968b2c 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -24,6 +24,7 @@ m,merge! use merging strategies to rebase i,interactive! let the user edit the list of commits to rebase x,exec=! add exec lines after each commit of the editable list k,keep-empty preserve empty commits during rebase +F,show-files Show files affected by each list of commit to rebase f,force-rebase! force rebase even if branch is up to date X,strategy-option=! pass the argument through to the merge strategy stat! display a diffstat of what changed upstream @@ -88,6 +89,7 @@ autosquash= keep_empty= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t gpg_sign_opt= +show_files= read_basic_state () { test -f "$state_dir/head-name" && @@ -336,6 +338,9 @@ do --gpg-sign=*) gpg_sign_opt="-S${1#--gpg-sign=}" ;; + --show-files|-F) + show_files=t + ;; --) shift break -- 2.1.0.244.g5796467.dirty