From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH 3/4] rebase: teach `reset_head()` to optionally skip the worktree
Date: Fri, 18 Jan 2019 15:18:02 +0100 (STD) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1901181516240.41@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <xmqqpntcclot.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Fri, 4 Jan 2019, Junio C Hamano wrote:
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > This is what the legacy (scripted) rebase does in
> > `move_to_original_branch`, and we will need this functionality in the
> > next commit.
>
> The move-to-original-branch helper does:
>
> - point $head_name to the commit pointed at by HEAD
> - point HEAD symref to $head_name
>
> without touching the index or the working tree files. It's not
> exactly "reset --soft" but more like "switch-branch --soft" ;-)
Right, but it does reset the HEAD softly.
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> > builtin/rebase.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/builtin/rebase.c b/builtin/rebase.c
> > index 768bea0da8..303175fdf1 100644
> > --- a/builtin/rebase.c
> > +++ b/builtin/rebase.c
> > @@ -337,6 +337,7 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
> >
> > #define RESET_HEAD_DETACH (1<<0)
> > #define RESET_HEAD_HARD (1<<1)
> > +#define RESET_HEAD_REFS_ONLY (1<<2)
>
> In the future codebase in 'pu', we have 1<<2 already taken by
> another topic, so I'll tell my rerere database that the bit
> assignment needs to be adjusted.
Okay.
> > static int reset_head(struct object_id *oid, const char *action,
> > const char *switch_to_branch, unsigned flags,
> > @@ -344,6 +345,7 @@ static int reset_head(struct object_id *oid, const char *action,
> > {
> > unsigned detach_head = flags & RESET_HEAD_DETACH;
> > unsigned reset_hard = flags & RESET_HEAD_HARD;
> > + unsigned refs_only = flags & RESET_HEAD_REFS_ONLY;
> > struct object_id head_oid;
> > struct tree_desc desc[2] = { { NULL }, { NULL } };
> > struct lock_file lock = LOCK_INIT;
> > @@ -359,7 +361,7 @@ static int reset_head(struct object_id *oid, const char *action,
> > if (switch_to_branch && !starts_with(switch_to_branch, "refs/"))
> > BUG("Not a fully qualified branch: '%s'", switch_to_branch);
> >
> > - if (hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) {
> > + if (!refs_only && hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) {
> > ret = -1;
> > goto leave_reset_head;
> > }
>
> Not touching the index, so no need to lock the index. Makes sense.
>
> > @@ -372,6 +374,9 @@ static int reset_head(struct object_id *oid, const char *action,
> > if (!oid)
> > oid = &head_oid;
> >
> > + if (flags & RESET_HEAD_REFS_ONLY)
> > + goto reset_head_refs;
> > +
>
> Why not "refs_only" that we already prepared above??? Are we
> munging that secondary variable before control comes here?
No, just an oversight. Will fix.
> In any case, not touching the index nor the working tree, so no need
> to call into the unpack_trees machinery. Makes sense.
>
> > memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
> > setup_unpack_trees_porcelain(&unpack_tree_opts, action);
> > unpack_tree_opts.head_idx = 1;
> > @@ -412,6 +417,7 @@ static int reset_head(struct object_id *oid, const char *action,
> > goto leave_reset_head;
> > }
> >
> > +reset_head_refs:
> > reflog_action = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);
>
> And the control continues from the point we update the reflog.
> Makes sense.
>
> > strbuf_addf(&msg, "%s: ", reflog_action ? reflog_action : "rebase");
> > prefix_len = msg.len;
>
> This helper is touched by two other topics in flight, and that was
> one of the reason why it took a bit longer than usual for me to
> merge this topic. Please sanity-check the result of the conflict
> resolution at the tip of 'pu' branch.
Sorry, I *just now* had time to take care of this patch series. I will
gladly check once you integrate the new patch series iteration.
Thanks,
Dscho
next prev parent reply other threads:[~2019-01-18 14:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 13:17 [PATCH 0/4] Let the builtin rebase call the git am command directly Johannes Schindelin via GitGitGadget
2018-12-21 13:17 ` [PATCH 1/4] rebase: move `reset_head()` into a better spot Johannes Schindelin via GitGitGadget
2019-01-04 18:39 ` Junio C Hamano
2018-12-21 13:17 ` [PATCH 2/4] rebase: avoid double reflog entry when switching branches Johannes Schindelin via GitGitGadget
2019-01-04 18:38 ` Junio C Hamano
2019-01-18 14:18 ` Johannes Schindelin
2018-12-21 13:17 ` [PATCH 3/4] rebase: teach `reset_head()` to optionally skip the worktree Johannes Schindelin via GitGitGadget
2019-01-04 18:38 ` Junio C Hamano
2019-01-04 18:40 ` Junio C Hamano
2019-01-18 14:18 ` Johannes Schindelin [this message]
2018-12-21 13:17 ` [PATCH 4/4] built-in rebase: call `git am` directly Johannes Schindelin via GitGitGadget
2019-01-04 18:38 ` Junio C Hamano
2019-01-18 14:15 ` Johannes Schindelin
2019-01-18 17:59 ` Junio C Hamano
2019-01-18 18:14 ` Johannes Schindelin
2019-01-04 23:19 ` Junio C Hamano
2019-01-07 17:19 ` Junio C Hamano
2019-01-18 15:09 ` [PATCH v2 0/4] Let the builtin rebase call the git am command directly Johannes Schindelin via GitGitGadget
2019-01-18 15:09 ` [PATCH v2 1/4] rebase: move `reset_head()` into a better spot Johannes Schindelin via GitGitGadget
2019-01-18 15:09 ` [PATCH v2 2/4] rebase: avoid double reflog entry when switching branches Johannes Schindelin via GitGitGadget
2019-01-18 15:09 ` [PATCH v2 3/4] rebase: teach `reset_head()` to optionally skip the worktree Johannes Schindelin via GitGitGadget
2019-01-18 15:09 ` [PATCH v2 4/4] built-in rebase: call `git am` directly Johannes Schindelin via GitGitGadget
2019-01-26 21:13 ` Alban Gruin
2019-01-29 9:46 ` Johannes Schindelin
2019-01-18 18:06 ` [PATCH v2 0/4] Let the builtin rebase call the git am command directly Junio C Hamano
2019-01-18 20:13 ` Junio C Hamano
2019-01-18 20:31 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.QRO.7.76.6.1901181516240.41@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).