Skip to content

status_should_ignore returns true for any path starting with "./" #3979

@jacwah

Description

@jacwah

As far as I can tell, status_should_ignore sets the ignored pointer to 1 for any path starting with "./". I do not expect the paths "file" and "./file" to give different results because they refer to the same thing. The documentation also doesn't mention any special case for "./*".

I wrote a program to illustrate this listed below.

#include <stdio.h>
#include <git2.h>
#include <git2/errors.h>

int main(int argc, char **argv)
{
	git_repository *repo = NULL;
	int status;

	status = git_repository_open(&repo, ".");

	if (status < 0) {
		fprintf(stderr, "error: %s\n", giterr_last()->message);
		return 1;
	}

	for (int i = 1; i < argc; i++) {
		char *filename = argv[i];
		int should_ignore = 0;

		status = git_status_should_ignore(&should_ignore, repo, filename);
		
		if (status < 0) {
			fprintf(stderr, "error: %s\n", giterr_last()->message);
			return 1;
		} else {
			printf("%s %s\n", should_ignore ? "ignr:\t" : "incl:\t", filename);
		}
	}

	return 0;
}

Running this in a just initialised git repository containing no .gitignore file gives the following results:

$ ./ignore ignore.c $PWD/ignore.c ./ignore.c
incl:	 ignore.c
incl:	 /Users/jacob/Code/gittest/ignore.c
ignr:	 ./ignore.c

This was tested on v0.24.2 and e3298a3 (current master) on OS X 10.12.1. Both versions were built with Homebrew.

I originally posted this as an issue for the rust wrapper around libgit2 at alexcrichton/git2-rs#164.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions