(#FE4) Program logs cause false-negative test

My solution writes logs. In stderr and in the folder “logs”. Frequent logs.

In this task I have to scan all the files in the current folder and calculate their hashes. I do such thing but during this I am writing stuf in “logs” directory. And yes, I calculate hash for the “logs/log.txt” file too. Which is getting updated after being processed by my code.

After my program finished its execution and printed the answer, your tester calculates hashes and for “logs/log.txt” it is different. The test is red, end of story.

(Not sure if this is fixable on your end, at least it should be written in task description)

Hey @natalka1122, could you confirm whether your program is writing the logs directory inside the working repository?

To avoid this, it’d be best to write logs outside the working directory, for example under /tmp.

Yes, my program writes logs inside working directory. I do not even need those logs, I have disabled them when I got what is happening and everything becomes fine.

The actual root cause of the issue is, quote from the task, “The official git implementation uses the staging area to determine what to write to the tree object. We’ll just assume that all files in the working directory are staged.”. That forces logs dir (or just a file) to be added inside tree, and spoils the test.

Although for me it was an interesting thing for find (why do we even need this staging area, git add . is a ceremony), I doubt it was intended

1 Like

Could you clarify whether this question is about the Git challenge specifically, or about Git in general?

No, here I tried to express my relationship with staging area before this challenge, that I did not quite understand its necessity and git add . was just a command executed blindly.

Got it! That makes sense.

As you get more familiar with Git, you’ll likely find yourself staging specific files instead of ., or using a GUI to achieve the same goal of selectively adding changes to the staging area.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.