From f38798f48dc8ed53fe001cc5a0d422f5c56b9d81 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 30 Aug 2013 16:56:45 -0500 Subject: [PATCH 1/5] reset: trivial refactoring After commit 3fde386 (reset [--mixed]: use diff-based reset whether or not pathspec was given), some code can be moved to the 'reset_type == MIXED' check. Let's move the code that is specific to MIXED. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/reset.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/builtin/reset.c b/builtin/reset.c index afa6e020e8..225e3f141e 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -326,8 +326,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix) struct lock_file *lock = xcalloc(1, sizeof(struct lock_file)); int newfd = hold_locked_index(lock, 1); if (reset_type == MIXED) { + int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; if (read_from_tree(pathspec, sha1)) return 1; + refresh_index(&the_index, flags, NULL, NULL, + _("Unstaged changes after reset:")); } else { int err = reset_index(sha1, reset_type, quiet); if (reset_type == KEEP && !err) @@ -336,12 +339,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) die(_("Could not reset index file to revision '%s'."), rev); } - if (reset_type == MIXED) { /* Report what has not been updated. */ - int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; - refresh_index(&the_index, flags, NULL, NULL, - _("Unstaged changes after reset:")); - } - if (write_cache(newfd, active_cache, active_nr) || commit_locked_index(lock)) die(_("Could not write new index file.")); From 82a0672f8ed4c63bf8420cd55f7307d40b9a6594 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 30 Aug 2013 16:56:46 -0500 Subject: [PATCH 2/5] branch: trivial style fix Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/branch.c b/branch.c index c5c6984cb5..546c4b4406 100644 --- a/branch.c +++ b/branch.c @@ -307,7 +307,7 @@ void create_branch(const char *head, start_name); if (real_ref && track) - setup_tracking(ref.buf+11, real_ref, track, quiet); + setup_tracking(ref.buf + 11, real_ref, track, quiet); if (!dont_change_ref) if (write_ref_sha1(lock, sha1, msg) < 0) From 4e83ab3e8d43beaa7a2097a2f34d3b9eb67525bb Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 30 Aug 2013 16:56:48 -0500 Subject: [PATCH 3/5] reset: trivial style cleanup Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/reset.c b/builtin/reset.c index 225e3f141e..7e65934a82 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -323,7 +323,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) die_if_unmerged_cache(reset_type); if (reset_type != SOFT) { - struct lock_file *lock = xcalloc(1, sizeof(struct lock_file)); + struct lock_file *lock = xcalloc(1, sizeof(*lock)); int newfd = hold_locked_index(lock, 1); if (reset_type == MIXED) { int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; From d521abf8900dc38f88ed8fbb007848fb2a812510 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 30 Aug 2013 16:56:49 -0500 Subject: [PATCH 4/5] add: trivial style cleanup Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/add.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 8266a9cb70..a1e1e0eeb9 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -336,7 +336,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix) git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ if (read_cache() < 0) - die (_("Could not read the index")); + die(_("Could not read the index")); init_revisions(&rev, prefix); rev.diffopt.context = 7; @@ -347,11 +347,11 @@ static int edit_patch(int argc, const char **argv, const char *prefix) DIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES); out = open(file, O_CREAT | O_WRONLY, 0666); if (out < 0) - die (_("Could not open '%s' for writing."), file); + die(_("Could not open '%s' for writing."), file); rev.diffopt.file = xfdopen(out, "w"); rev.diffopt.close_file = 1; if (run_diff_files(&rev, 0)) - die (_("Could not write patch")); + die(_("Could not write patch")); launch_editor(file, NULL, NULL); @@ -364,7 +364,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix) child.git_cmd = 1; child.argv = apply_argv; if (run_command(&child)) - die (_("Could not apply '%s'"), file); + die(_("Could not apply '%s'"), file); unlink(file); free(file); @@ -598,7 +598,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) unplug_bulk_checkin(); - finish: +finish: if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || commit_locked_index(&lock_file)) From b07f7296080b20f5cc2069ce2761cacdd79b3432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 8 Sep 2013 17:21:44 +0200 Subject: [PATCH 5/5] pull: use $curr_branch_short more One of the first things git-pull.sh does is setting $curr_branch to the target of HEAD and $curr_branch_short to the same but with the leading "refs/heads/" removed. Simplify the code by using $curr_branch_short instead of setting $curr_branch to the same shortened value. The only other use of $curr_branch in that function doesn't have to be replaced with $curr_branch_short because it just checks if the string is empty. That property is the same with or without the prefix unless HEAD points to "refs/heads/" alone, which is invalid. Noticed-by: Felipe Contreras Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- git-pull.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/git-pull.sh b/git-pull.sh index f0df41c841..d8b2708a1d 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -166,9 +166,8 @@ error_on_no_merge_candidates () { op_prep=with fi - curr_branch=${curr_branch#refs/heads/} - upstream=$(git config "branch.$curr_branch.merge") - remote=$(git config "branch.$curr_branch.remote") + upstream=$(git config "branch.$curr_branch_short.merge") + remote=$(git config "branch.$curr_branch_short.remote") if [ $# -gt 1 ]; then if [ "$rebase" = true ]; then