Introduction
was introduced by Linus Torvalds after some while to handle the huge amount of patches submitted by the developpers during the early life of . It is designed to be a patch database.
helps developpers to easily create patches (called commits) and share them with others. Previously it was done by mailing the patches to the maintainer of the project. Each commit contains also an explanation for the patch. This is super handy to understand some part of the code because it's like each patch contains its own documentation. Here is an example of a patch written in the repository:
From 40249c6962075c040fd071339acae524f18bfac9 Mon Sep 17 00:00:00 2001
From: Peter Oberparleiter <oberpar@linux.ibm.com>
Date: Thu, 10 Sep 2020 14:52:01 +0200
Subject: [PATCH] gcov: add support for GCC 10.1
Using gcov to collect coverage data for kernels compiled with GCC 10.1
causes random malfunctions and kernel crashes. This is the result of a
changed GCOV_COUNTERS value in GCC 10.1 that causes a mismatch between
the layout of the gcov_info structure created by GCC profiling code and
the related structure used by the kernel.
Fix this by updating the in-kernel GCOV_COUNTERS value. Also re-enable
config GCOV_KERNEL for use with GCC 10.
Reported-by: Colin Ian King <colin.king@canonical.com>
Reported-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Tested-by: Leon Romanovsky <leonro@nvidia.com>
Tested-and-Acked-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
kernel/gcov/Kconfig | 1 -
kernel/gcov/gcc_4_7.c | 4 +++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index bb4b680e8455..3110c77230c7 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -4,7 +4,6 @@ menu "GCOV-based kernel profiling"
config GCOV_KERNEL
bool "Enable gcov-based kernel profiling"
depends on DEBUG_FS
- depends on !CC_IS_GCC || GCC_VERSION < 100000
select CONSTRUCTORS if !UML
default n
help
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 908fdf5098c3..53c67c87f141 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -19,7 +19,9 @@
#include <linux/vmalloc.h>
#include "gcov.h"
-#if (__GNUC__ >= 7)
+#if (__GNUC__ >= 10)
+#define GCOV_COUNTERS 8
+#elif (__GNUC__ >= 7)
#define GCOV_COUNTERS 9
#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
#define GCOV_COUNTERS 10
--
2.43.1
As you can see, there is a first line in the patch note after the Subject tag, followed by an extensive explanation of the patch reason and goal. You will also find other interesting tags like Reported-by and Signed-off-by. These tags are optionnal but useful in huge and massively distributed projects like . They are documented here.
New features where introduced to even increase the developper productivity. Some of them are the ability to work on branches (local forks of the code) and merge them, rebase them, cherry pick a commit from another branch, the ability the squash commits, split them, reorder them in a branch, reword the patch note and so on... These are essential technics to understand and master in order to be efficient at developping code.
To finish this introduction, let's have a look at a database. If you dive into a cloned git repository (not a bare one), you will find this kind of structure:
/all_your_code_and_subdirectories /.git /branches/ # Describe the branches /config # Contains the local configuration of the project (the global one is in ~/.gitconfig) /description # The repository description, but mostly unused nowadays /HEAD # The currently stored state of the repository /hooks/ # Some hooks you can use to perform complementary actions after or before some git commands /index # The description of the modifications with HEAD /info/ # To exclude data you don't want to put in .gitignore /logs/ # History of the local actions (not distributed). Mainly used for git reflog command /objects/ # Where the data are stored, mostly the patches /ORIG_HEAD # The HEAD of the main remote /packed-refs # The list of registered refs /refs/ # The links between the patches
As you can see, the database is accessible for understanding and a good documentation is provided here at the section 10. Git Internals. By the way, you can download the git documentation as pdf here