Skip to content

Commit c48d73b

Browse files
mehul2029gitster
authored andcommitted
git-pull.c: introduce git_pull_config()
git-pull makes a seperate call to git_config_get_bool() to read the value of "rebase.autostash". This can be reduced as a call to git_config() is already there in the code. Introduce a callback function git_pull_config() to read "rebase.autostash" along with other variables. Helped-by: Junio C Hamano <[email protected]> Helped-by: Paul Tan <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Mehul Jain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab5d01a commit c48d73b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

builtin/pull.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static char *opt_commit;
8686
static char *opt_edit;
8787
static char *opt_ff;
8888
static char *opt_verify_signatures;
89+
static int config_autostash;
8990
static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
9091
static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
9192
static char *opt_gpg_sign;
@@ -305,6 +306,18 @@ static enum rebase_type config_get_rebase(void)
305306
return REBASE_FALSE;
306307
}
307308

309+
/**
310+
* Read config variables.
311+
*/
312+
static int git_pull_config(const char *var, const char *value, void *cb)
313+
{
314+
if (!strcmp(var, "rebase.autostash")) {
315+
config_autostash = git_config_bool(var, value);
316+
return 0;
317+
}
318+
return git_default_config(var, value, cb);
319+
}
320+
308321
/**
309322
* Returns 1 if there are unstaged changes, 0 otherwise.
310323
*/
@@ -823,7 +836,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
823836
if (opt_rebase < 0)
824837
opt_rebase = config_get_rebase();
825838

826-
git_config(git_default_config, NULL);
839+
git_config(git_pull_config, NULL);
827840

828841
if (read_cache_unmerged())
829842
die_resolve_conflict("Pull");
@@ -835,12 +848,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
835848
hashclr(orig_head);
836849

837850
if (opt_rebase) {
838-
int autostash = 0;
851+
int autostash = config_autostash;
839852

840853
if (is_null_sha1(orig_head) && !is_cache_unborn())
841854
die(_("Updating an unborn branch with changes added to the index."));
842855

843-
git_config_get_bool("rebase.autostash", &autostash);
844856
if (!autostash)
845857
die_on_unclean_work_tree(prefix);
846858

0 commit comments

Comments
 (0)