git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: git@vger.kernel.org, "Henré Botha" <henrebotha@gmail.com>,
	"Jeff King" <peff@peff.net>
Subject: Re: [PATCH 1/5] worktree: add skeleton "repair" command
Date: Thu, 27 Aug 2020 09:08:05 -0700	[thread overview]
Message-ID: <xmqqr1rsqdga.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200827082129.56149-2-sunshine@sunshineco.com> (Eric Sunshine's message of "Thu, 27 Aug 2020 04:21:25 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

> Worktree administrative files can become corrupted or outdated due to
> external factors. Although, it is often possible to recover from such
> situations by hand-tweaking these files, doing so requires intimate
> knowledge of worktree internals. While information necessary to make
> such repairs manually can be obtained from git-worktree.txt and
> gitrepository-layout.txt, we can assist users more directly by teaching
> git-worktree how to repair its administrative files itself (at least to
> some extent). Therefore, add a "git worktree repair" command which
> attempts to correct common problems which may arise due to factors
> beyond Git's control.
>
> At this stage, the "repair" command is a mere skeleton; subsequent
> commits will flesh out the functionality.

Sounds good.  It looked a bit odd to have skeleton test script only
to reserve its test number, but it is just odd and not wrong.

Let's read on.

> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  Documentation/git-worktree.txt |  6 ++++++
>  builtin/worktree.c             | 15 +++++++++++++++
>  t/t2406-worktree-repair.sh     | 11 +++++++++++
>  3 files changed, 32 insertions(+)
>  create mode 100755 t/t2406-worktree-repair.sh
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index 6ee6ec7982..ae432d39a8 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -15,6 +15,7 @@ SYNOPSIS
>  'git worktree move' <worktree> <new-path>
>  'git worktree prune' [-n] [-v] [--expire <expire>]
>  'git worktree remove' [-f] <worktree>
> +'git worktree repair'
>  'git worktree unlock' <worktree>
>  
>  DESCRIPTION
> @@ -110,6 +111,11 @@ and no modification in tracked files) can be removed. Unclean working
>  trees or ones with submodules can be removed with `--force`. The main
>  working tree cannot be removed.
>  
> +repair::
> +
> +Repair working tree administrative files, if possible, if they have
> +become corrupted or outdated due to external factors.
> +
>  unlock::
>  
>  Unlock a working tree, allowing it to be pruned, moved or deleted.
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> index 378f332b5d..88af412d4f 100644
> --- a/builtin/worktree.c
> +++ b/builtin/worktree.c
> @@ -1030,6 +1030,19 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
>  	return ret;
>  }
>  
> +static int repair(int ac, const char **av, const char *prefix)
> +{
> +	struct option options[] = {
> +		OPT_END()
> +	};
> +	int rc = 0;
> +
> +	ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
> +	if (ac)
> +		usage_with_options(worktree_usage, options);
> +	return rc;
> +}
> +
>  int cmd_worktree(int ac, const char **av, const char *prefix)
>  {
>  	struct option options[] = {
> @@ -1056,5 +1069,7 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
>  		return move_worktree(ac - 1, av + 1, prefix);
>  	if (!strcmp(av[1], "remove"))
>  		return remove_worktree(ac - 1, av + 1, prefix);
> +	if (!strcmp(av[1], "repair"))
> +		return repair(ac - 1, av + 1, prefix);
>  	usage_with_options(worktree_usage, options);
>  }
> diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh
> new file mode 100755
> index 0000000000..cc679e1a21
> --- /dev/null
> +++ b/t/t2406-worktree-repair.sh
> @@ -0,0 +1,11 @@
> +#!/bin/sh
> +
> +test_description='test git worktree repair'
> +
> +. ./test-lib.sh
> +
> +test_expect_success setup '
> +	test_commit init
> +'
> +
> +test_done

  reply	other threads:[~2020-08-27 16:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27  8:21 [PATCH 0/5] add "git worktree repair" command Eric Sunshine
2020-08-27  8:21 ` [PATCH 1/5] worktree: add skeleton "repair" command Eric Sunshine
2020-08-27 16:08   ` Junio C Hamano [this message]
2020-08-27 19:30     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 2/5] worktree: teach "repair" to fix worktree back-links to main worktree Eric Sunshine
2020-08-27 17:05   ` Junio C Hamano
2020-08-30  7:20     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 3/5] worktree: teach "repair" to fix outgoing links to worktrees Eric Sunshine
2020-08-27 17:14   ` Junio C Hamano
2020-08-30  7:36     ` Eric Sunshine
2020-08-31 19:07       ` Junio C Hamano
2020-08-28  2:15   ` Johannes Schindelin
2020-08-28 16:27     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 4/5] init: teach --separate-git-dir to repair linked worktrees Eric Sunshine
2020-08-27  8:21 ` [PATCH 5/5] init: make --separate-git-dir work from within linked worktree Eric Sunshine
2020-08-31  6:57 ` [PATCH v2 0/5] add "git worktree repair" command Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 1/5] worktree: add skeleton "repair" command Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 2/5] worktree: teach "repair" to fix worktree back-links to main worktree Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 3/5] worktree: teach "repair" to fix outgoing links to worktrees Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 4/5] init: teach --separate-git-dir to repair linked worktrees Eric Sunshine
2020-08-31  6:58   ` [PATCH v2 5/5] init: make --separate-git-dir work from within linked worktree Eric Sunshine
2020-08-31 18:59   ` [PATCH v2 0/5] add "git worktree repair" command Junio C Hamano

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=xmqqr1rsqdga.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=henrebotha@gmail.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.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).