From: brian m. carlson Date: Mon, 30 Oct 2023 16:26:58 GMT Subject: [PATCH v2 1/1] merge-file: add an option to process object IDs Message-ID: <20231030162658.567523-2-sandals@crustytoothpaste.net> In-Reply-To: <20231030162658.567523-1-sandals@crustytoothpaste.net> From: "brian m. carlson" git merge-file knows how to merge files on the file system already. It would be helpful, however, to allow it to also merge single blobs. Teach it an `--object-id` option which means that its arguments are object IDs and not files to allow it to do so. Since we obviously won't be writing the data to the first argument, imply the -p option so we write to standard output. We handle the empty blob specially since read_mmblob doesn't read it directly and otherwise users cannot specify an empty ancestor. Signed-off-by: brian m. carlson --- Documentation/git-merge-file.txt | 20 +++++++++++ builtin/merge-file.c | 62 +++++++++++++++++++++++--------- t/t6403-merge-file.sh | 58 ++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 16 deletions(-) diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt index 7e9093fab6..a4de2bd297 100644 --- a/Documentation/git-merge-file.txt +++ b/Documentation/git-merge-file.txt @@ -12,6 +12,9 @@ SYNOPSIS 'git merge-file' [-L [-L [-L ]]] [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] [--[no-]diff3] +'git merge-file' --object-id [-L [-L [-L ]]] + [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] + [--[no-]diff3] DESCRIPTION @@ -40,6 +43,10 @@ however, these conflicts are resolved favouring lines from ``, lines from ``, or lines from both respectively. The length of the conflict markers can be given with the `--marker-size` option. +If `--object-id` is specified, exactly the same behavior occurs, except that +instead of specifying what to merge as files, it is specified as a list of +object IDs referring to blobs. + The exit value of this program is negative on error, and the number of conflicts otherwise (truncated to 127 if there are more than that many conflicts). If the merge was clean, the exit value is 0. @@ -52,6 +59,14 @@ linkgit:git[1]. OPTIONS ------- +--object-id:: + Specify the contents to merge as blobs in the current repository instead of + files. In this case, the operation must take place within a valid repository. ++ +If the `-p` option is specified, the merged file (including conflicts, if any) +goes to standard output as normal; otherwise, the merged file is written to the +object store and the object ID of its blob is written to standard output. + -L