libgit2 / libgit2/libgit2

Error when applying patch that removes submodule

Open
#6,779 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
10.6k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

Reproduction steps

on any existing repo that contains a submodule generate a diff that removes it:

$ git rm <submodule name>
$ git diff --staged > remove-submodule.patch

(I used git 2.25.1)
my generated patch looks like this:

diff --git a/.gitmodules b/.gitmodules
index 1b59123..e69de29 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "submodule"]
-	path = submodule
-	url = ../submodule
diff --git a/submodule b/submodule
deleted file mode 160000
index xxxxx..0000000
--- a/fus-modules
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit xxxxxxxxxxxxxxxxxxxxxxxxxxx

And when running this small program that uses libgit2:
test.c.txt
built using
gcc test.c -lgit2 -L <path to libgit2>/libgit2/build/ -Wall -pedantic -I <path to libgit2>/libgit2/include/
And run like this:
LD_LIBRARY_PATH=<path to libgit2>/libgit2/build/ ./a.out <Path to repo> <path to patch file>

Expected behavior

It successfully applies the change

Actual behavior

Error applying patch: -1 no error

I checked also modifying the submodule and it fails too

Version of libgit2 (release number or SHA1)

1.3.0 and main ( d74d491481831ddcd23575d376e56d2197e95910 )

Operating system(s) tested

Linux (Ubuntu 20.04)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached test.c.txt program and reproduce the failure using a patch that removes or modifies a submodule. Trace the patch-application path for the reported “-1 no error” result, then verify that the supplied removal patch applies successfully on Linux. The issue does not name a source file or regression test, so locating the relevant implementation and test coverage will require repository research.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, git
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.