From 8077612ea12e80b20e307e279916710b99fe6362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C3=85gren?= Date: Wed, 1 Nov 2023 19:24:18 +0000 Subject: [PATCH 1/2] git-merge-file doc: drop "-file" from argument placeholders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `git merge-file` takes three positional arguments. Each of them is documented as ``. In preparation for teaching this command to alternatively take three object IDs, make these placeholders a bit more generic by dropping the "-file" parts. Instead, clarify early that the three arguments are filenames. Even after the next commit, we can afford to present this file-centric view up front and in the general discussion, since it will remain the default one. Signed-off-by: Martin Ă…gren Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- Documentation/git-merge-file.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt index 7e9093fab6..bf0a18cf02 100644 --- a/Documentation/git-merge-file.txt +++ b/Documentation/git-merge-file.txt @@ -11,19 +11,20 @@ SYNOPSIS [verse] 'git merge-file' [-L [-L [-L ]]] [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] - [--[no-]diff3] + [--[no-]diff3] DESCRIPTION ----------- -'git merge-file' incorporates all changes that lead from the `` -to `` into ``. The result ordinarily goes into -``. 'git merge-file' is useful for combining separate changes -to an original. Suppose `` is the original, and both -`` and `` are modifications of ``, +Given three files ``, `` and ``, +'git merge-file' incorporates all changes that lead from `` +to `` into ``. The result ordinarily goes into +``. 'git merge-file' is useful for combining separate changes +to an original. Suppose `` is the original, and both +`` and `` are modifications of ``, then 'git merge-file' combines both changes. -A conflict occurs if both `` and `` have changes +A conflict occurs if both `` and `` have changes in a common segment of lines. If a conflict is found, 'git merge-file' normally outputs a warning and brackets the conflict with lines containing <<<<<<< and >>>>>>> markers. A typical conflict will look like this: @@ -36,8 +37,8 @@ normally outputs a warning and brackets the conflict with lines containing If there are conflicts, the user should edit the result and delete one of the alternatives. When `--ours`, `--theirs`, or `--union` option is in effect, -however, these conflicts are resolved favouring lines from ``, -lines from ``, or lines from both respectively. The length of the +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. The exit value of this program is negative on error, and the number of @@ -62,7 +63,7 @@ OPTIONS -p:: Send results to standard output instead of overwriting - ``. + ``. -q:: Quiet; do not warn about conflicts. From e1068f0ad40f8e724513885e5a9ebb8548885e02 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Wed, 1 Nov 2023 19:24:19 +0000 Subject: [PATCH 2/2] merge-file: add an option to process object IDs 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. 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 Signed-off-by: Junio C Hamano --- Documentation/git-merge-file.txt | 19 +++++++++- builtin/merge-file.c | 62 +++++++++++++++++++++++--------- t/t6403-merge-file.sh | 58 ++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 17 deletions(-) diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt index bf0a18cf02..6a081eacb7 100644 --- a/Documentation/git-merge-file.txt +++ b/Documentation/git-merge-file.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git merge-file' [-L [-L [-L ]]] [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] - [--[no-]diff3] + [--[no-]diff3] [--object-id] DESCRIPTION @@ -41,6 +41,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. @@ -53,6 +57,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