diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-10-07 11:32:59 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-07 11:33:00 +0900 |
commit | 337e3f2b49a954d1c3279fe71990cac8a4dfd447 (patch) | |
tree | 2fe3664c52e360c07b99ad1c348c9ee001144e2a | |
parent | Merge branch 'hb/hg-to-git-py3' (diff) | |
parent | sha1_name: simplify strbuf handling in interpret_nth_prior_checkout() (diff) | |
download | tgif-337e3f2b49a954d1c3279fe71990cac8a4dfd447.tar.xz |
Merge branch 'rs/nth-switch-code-simplification'
Code simplification.
* rs/nth-switch-code-simplification:
sha1_name: simplify strbuf handling in interpret_nth_prior_checkout()
-rw-r--r-- | sha1-name.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sha1-name.c b/sha1-name.c index 7a047e9e2b..200eb373ad 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1295,7 +1295,7 @@ static int get_oid_oneline(struct repository *r, struct grab_nth_branch_switch_cbdata { int remaining; - struct strbuf buf; + struct strbuf *sb; }; static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid, @@ -1313,8 +1313,8 @@ static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid return 0; if (--(cb->remaining) == 0) { len = target - match; - strbuf_reset(&cb->buf); - strbuf_add(&cb->buf, match, len); + strbuf_reset(cb->sb); + strbuf_add(cb->sb, match, len); return 1; /* we are done */ } return 0; @@ -1347,18 +1347,15 @@ static int interpret_nth_prior_checkout(struct repository *r, if (nth <= 0) return -1; cb.remaining = nth; - strbuf_init(&cb.buf, 20); + cb.sb = buf; retval = refs_for_each_reflog_ent_reverse(get_main_ref_store(r), "HEAD", grab_nth_branch_switch, &cb); if (0 < retval) { - strbuf_reset(buf); - strbuf_addbuf(buf, &cb.buf); retval = brace - name + 1; } else retval = 0; - strbuf_release(&cb.buf); return retval; } |